package com.itec.learn.mongodb.repository;

import com.itec.learn.mongodb.entity.Patents;
import com.itec.learn.mongodb.entity.PatentsRowMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Author: Yiqun Chen
 * Date:   2017/9/20
 */
@Repository
public class PatentsRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Transactional(readOnly = true)
    public List<Patents> findAll() {
        return jdbcTemplate.query("select * from view_patents", new PatentsRowMapper());
    }
}
